package shoppingmall.manage.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import shoppingmall.manage.pojo.CommodityStandard;

import java.util.List;

/**
 * 商品规格相关-mapper层
 */
@Mapper
public interface CommodityStandardMapper {

    /**
     * 分页查询所有商品规格
     */
    @Select("select * from tb_commodity_standard limit #{start}, #{pageSize}")
    public List<CommodityStandard> getCommodityStandardList (int start, int pageSize);


    /**
     * *****查询所有商品规格(所有数据查询-用作匹配订单的规格名称)
     */
    public List<CommodityStandard> getAllCommodityStandardList ();

    /**
     * 查询商品规格总记录条数
     */
    @Select("select count(*) from tb_commodity_standard")
    public int getCommodityStandardCount ();

    /**
     * 查询某个商品的所有规格集合
     */
    @Select("select * from tb_commodity_standard where commodity_id = #{commodityId}")
    public List<CommodityStandard> getCommodityStandardListByCommodityId (int commodityId);

    /**
     * 查询某个商品的所有规格集合总条数
     */
    @Select("select count(*) from tb_commodity_standard where commodity_id = #{commodity}")
    public int getCommodityStandardCountByCommodityId (int commodityId);

    /**
     * 插入一条规格数据(为某个商品添加一条规格信息)
     */
    public void saveCommodityStandard (CommodityStandard commodityStandard);

    /**
     * 更新一条规格数据
     */
    public void updateCommodityStandard (CommodityStandard commodityStandard);

    /**
     * 删除一条规格数据
     */
    @Delete("delete from tb_commodity_standard where id = #{standardId}")
    public void deleteCommodityStandard (int standardId);
}
